/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package classdiagram.impl;

import classdiagram.ClassdiagramPackage;
import classdiagram.Relation;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Relation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link classdiagram.impl.RelationImpl#getOrigin <em>Origin</em>}</li>
 *   <li>{@link classdiagram.impl.RelationImpl#getDestination <em>Destination</em>}</li>
 *   <li>{@link classdiagram.impl.RelationImpl#getName <em>Name</em>}</li>
 *   <li>{@link classdiagram.impl.RelationImpl#getCardOrigin <em>Card Origin</em>}</li>
 *   <li>{@link classdiagram.impl.RelationImpl#getCardDest <em>Card Dest</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class RelationImpl extends EObjectImpl implements Relation {
	/**
	 * The cached value of the '{@link #getOrigin() <em>Origin</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOrigin()
	 * @generated
	 * @ordered
	 */
	protected classdiagram.Class origin;

	/**
	 * The cached value of the '{@link #getDestination() <em>Destination</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDestination()
	 * @generated
	 * @ordered
	 */
	protected classdiagram.Class destination;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getCardOrigin() <em>Card Origin</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCardOrigin()
	 * @generated
	 * @ordered
	 */
	protected static final String CARD_ORIGIN_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCardOrigin() <em>Card Origin</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCardOrigin()
	 * @generated
	 * @ordered
	 */
	protected String cardOrigin = CARD_ORIGIN_EDEFAULT;

	/**
	 * The default value of the '{@link #getCardDest() <em>Card Dest</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCardDest()
	 * @generated
	 * @ordered
	 */
	protected static final String CARD_DEST_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getCardDest() <em>Card Dest</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCardDest()
	 * @generated
	 * @ordered
	 */
	protected String cardDest = CARD_DEST_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RelationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ClassdiagramPackage.Literals.RELATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public classdiagram.Class getOrigin() {
		if (origin != null && origin.eIsProxy()) {
			InternalEObject oldOrigin = (InternalEObject)origin;
			origin = (classdiagram.Class)eResolveProxy(oldOrigin);
			if (origin != oldOrigin) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ClassdiagramPackage.RELATION__ORIGIN, oldOrigin, origin));
			}
		}
		return origin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public classdiagram.Class basicGetOrigin() {
		return origin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOrigin(classdiagram.Class newOrigin) {
		classdiagram.Class oldOrigin = origin;
		origin = newOrigin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClassdiagramPackage.RELATION__ORIGIN, oldOrigin, origin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public classdiagram.Class getDestination() {
		if (destination != null && destination.eIsProxy()) {
			InternalEObject oldDestination = (InternalEObject)destination;
			destination = (classdiagram.Class)eResolveProxy(oldDestination);
			if (destination != oldDestination) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ClassdiagramPackage.RELATION__DESTINATION, oldDestination, destination));
			}
		}
		return destination;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public classdiagram.Class basicGetDestination() {
		return destination;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDestination(classdiagram.Class newDestination) {
		classdiagram.Class oldDestination = destination;
		destination = newDestination;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClassdiagramPackage.RELATION__DESTINATION, oldDestination, destination));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClassdiagramPackage.RELATION__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCardOrigin() {
		return cardOrigin;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCardOrigin(String newCardOrigin) {
		String oldCardOrigin = cardOrigin;
		cardOrigin = newCardOrigin;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClassdiagramPackage.RELATION__CARD_ORIGIN, oldCardOrigin, cardOrigin));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getCardDest() {
		return cardDest;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCardDest(String newCardDest) {
		String oldCardDest = cardDest;
		cardDest = newCardDest;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClassdiagramPackage.RELATION__CARD_DEST, oldCardDest, cardDest));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ClassdiagramPackage.RELATION__ORIGIN:
				if (resolve) return getOrigin();
				return basicGetOrigin();
			case ClassdiagramPackage.RELATION__DESTINATION:
				if (resolve) return getDestination();
				return basicGetDestination();
			case ClassdiagramPackage.RELATION__NAME:
				return getName();
			case ClassdiagramPackage.RELATION__CARD_ORIGIN:
				return getCardOrigin();
			case ClassdiagramPackage.RELATION__CARD_DEST:
				return getCardDest();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ClassdiagramPackage.RELATION__ORIGIN:
				setOrigin((classdiagram.Class)newValue);
				return;
			case ClassdiagramPackage.RELATION__DESTINATION:
				setDestination((classdiagram.Class)newValue);
				return;
			case ClassdiagramPackage.RELATION__NAME:
				setName((String)newValue);
				return;
			case ClassdiagramPackage.RELATION__CARD_ORIGIN:
				setCardOrigin((String)newValue);
				return;
			case ClassdiagramPackage.RELATION__CARD_DEST:
				setCardDest((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ClassdiagramPackage.RELATION__ORIGIN:
				setOrigin((classdiagram.Class)null);
				return;
			case ClassdiagramPackage.RELATION__DESTINATION:
				setDestination((classdiagram.Class)null);
				return;
			case ClassdiagramPackage.RELATION__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ClassdiagramPackage.RELATION__CARD_ORIGIN:
				setCardOrigin(CARD_ORIGIN_EDEFAULT);
				return;
			case ClassdiagramPackage.RELATION__CARD_DEST:
				setCardDest(CARD_DEST_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ClassdiagramPackage.RELATION__ORIGIN:
				return origin != null;
			case ClassdiagramPackage.RELATION__DESTINATION:
				return destination != null;
			case ClassdiagramPackage.RELATION__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ClassdiagramPackage.RELATION__CARD_ORIGIN:
				return CARD_ORIGIN_EDEFAULT == null ? cardOrigin != null : !CARD_ORIGIN_EDEFAULT.equals(cardOrigin);
			case ClassdiagramPackage.RELATION__CARD_DEST:
				return CARD_DEST_EDEFAULT == null ? cardDest != null : !CARD_DEST_EDEFAULT.equals(cardDest);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", cardOrigin: ");
		result.append(cardOrigin);
		result.append(", cardDest: ");
		result.append(cardDest);
		result.append(')');
		return result.toString();
	}

} //RelationImpl
